package pattern15.company;

import java.util.ArrayList;

/**
 * 具体的公司类非叶子节点
 * @author wdl
 */
public class ConcreteCompany extends BaseCompany{
    public ConcreteCompany(String name) {
        super(name);
    }

    private ArrayList<BaseCompany> companies=new ArrayList<>();
    @Override
    public void add(BaseCompany company) {
        companies.add(company);
    }

    @Override
    public void remove(BaseCompany company) {
        companies.remove(company);
    }

    @Override
    public void display(int depth) {
        for (int i=0;i<depth;i++){
            System.out.print("-");
        }
        System.out.println(name);
        for (BaseCompany company:companies){
            company.display(depth+2);
        }
    }

    @Override
    public void lineOfDuty() {
        for (BaseCompany company:companies){
            company.lineOfDuty();
        }
    }
}
